<@t.plat_body pageid="order_list">
<script type="text/javascript" src="${base}/js/plugins/datatables/datatables.min.js"></script>
<script type="text/javascript" src="${base}/js/plugins/datatables/datatables_basic.js"></script>
<script type='text/javascript' src='${base}/js/plugins/laydate/laydate.js'></script>
<style>
    .dataTable.table>thead>tr>th, .dataTable.table>tbody>tr>th, .dataTable.table>tfoot>tr>th, .dataTable.table>thead>tr>td, .dataTable.table>tbody>tr>td, .dataTable.table>tfoot>tr>td{
        padding: 4px;
    }
    .query-talbe>tr>td{
        width: 60px;
    }
    /*.form-control{*/
        /*height: 28px;*/
    /*}*/
    .datatable-header, .datatable-footer{
        padding-top: 0px;
    }
</style>
<div class="panel panel-flat" style="margin-bottom: 0px;border-bottom: none">
    <div class="panel-heading">
        <h6 class="panel-title">平台账单列表</h6>
        <div class="heading-elements">
            <ul class="icons-list">
                <li><a data-action="collapse" data-popup="tooltip" ></a></li>
                <#--<li><a data-action="reload" data-popup="tooltip" title="Reload"></a></li>-->
                <#--<li><a data-action="close" data-popup="tooltip" title="Close"></a></li>-->
            </ul>
        </div>
    </div>
    <div class="panel-body">
        <form id="searchForm">
            <input id="category" name="category" type="hidden"/>
            <input id="areacode" name="areacode" type="hidden"/>
            <table class="table table-bordered query-talbe">
                <tr>
                    <th>手机号：</th>
                    <td >
                        <input class="form-control" type="text" id="mobile" name="mobile" />
                    </td>
                    <th>证件号：</th>
                    <td >
                        <input class="form-control" type="text" id="idno" name="idno" />
                    </td>
                    <th>支付方式：</th>
                    <td >
                        <select name="payway" id="payway" class="form-control">
                            <option value="">请选择</option>
                            <#list payways as p>
                                <option value="${p.code}">${p.name}</option>
                            </#list>

                        </select>
                    </td>


                </tr>
                <tr>

                    <th>开始时间：</th>
                    <td >
                        <input type="text" id="start"  name="start" size="30" class="form-control" />
                    </td>
                    <th>结束时间：</th>
                    <td >
                        <input  type="text" id="end"  name="end" size="30" class="form-control" />
                    </td>
                    <td colspan="2"  style="text-align: center" align="center">
                        <button type="button" onclick="table.ajax.reload();" class="btn btn-primary btn-small">查询</button>
                    </td>


                </tr>
            </table>
        </form>
    </div>
</div>
<div class="panel panel-flat" style="border-top: none">
    <div class="panel-body" style="padding-top: 0px">
        <table class="listTable table table-striped table-bordered dataTable" id="userTable">
        </table>
    </div>
</div>
<script>

    var contexts={},payways={};
    $('#payway').find('option').each(function () {
        var code=$(this).val();
        var name=$(this).text();
        payways[code]=name;
    });
    function exportClick() {
        var data=queryData();
        var index = showLoadingResult();
        $.ajax({
            contentType:'application/json;charset=UTF-8',
            type: "POST",
            url: '${base}/rp/export/order',
            cache: false, //禁用缓存
            data: JSON.stringify(data), //传入组装的参数
            dataType: "json",
            timeout:10000000000,
            success: function (result) {
                closeLoadingResult(index);
                if(result.extra){
                    $.download('${base}/export/download/'+result.extra.path)
                }else{
                    alertError('导出失败');
                }
            }
        });
    }
    function queryData() {
        var sno=$('#sno').val();
        var context=$('#context').val();
        var idno=$('#idno').val();
        var payway=$('#payway').val();
        var start=$('#start').val();
        var end=$('#end').val();
        var data={};

        if(context){
            data.context=context;
        }

        if(sno){
            data.sno=sno;
        }
        if(payway){
            data.payway=payway;
        }
        if(start){
            data.start=start;
        }
        if(end){
            data.end=end+' 23:59:59';
        }
        return data;
    }
    var recordsTotal=0;
    var table;
    $(function () {
        $('#sno').keyup(function (evt) {
            if(evt.keyCode==13){
                table.ajax.reload();
            }
        });
        table=ajaxServerTable('userTable', [
            {
                dataIndex: 'mobile',
                title: "手机号",
                sWidth: '100px',
            },
            {
                dataIndex: 'name',
                title: "姓名",
                sWidth: '80px'
            },
            {
                dataIndex: 'idno',
                title: "证件号",
                sWidth: '100px'
            },
            {
                dataIndex: 'money',
                title: "金额",
                sWidth: '100px',
                render: function (data, type, full) {
                    return data/100;
                }
            },{
                dataIndex: 'createdate',
                type: 'datetime',
                title: "创建时间",
                sWidth: '140px'
            },
            {
                dataIndex: 'paywaycode',
                title: "支付方式",
                sWidth: '100px',
                render: function (data, type, full) {
                    return payways[data] || '';
                }
            },
            {
                dataIndex: 'notice',
                title: "是否通知",
                sWidth: '100px',
                render: function (data, type, full) {
                    return (data=='1')?'是':'否';
                }
            },{
                dataIndex: 'noticedate',
                type: 'datetime',
                sWidth: '140px',
                title: "通知时间"
            },{
                dataIndex: 'rcn',
                sWidth: '150px',
                title: "流水"
            },{
                dataIndex: 'description',
                title: "备注",
                sWidth: '200px'
            }

        ],{
            scrollX: true,
            bLengthChange:false,
            iDisplayLength:25,
            ajax: function (data, callback, settings) {
                //封装请求参数
                var param = {};
                param.limit = data.length;//页面显示记录条数，在页面显示每页显示多少项的时候
                param.start = data.start;//开始的记录序号
                param.page = (data.start / data.length) + 1;//当前页码
                postJSON('pl/order/list_order',$.extend(param, queryData()),function (result) {
                    //setTimeout仅为测试延迟效果
                    setTimeout(function () {
                        //封装返回数据
                        var returnData = {};
                        returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回
                        returnData.recordsTotal = result.total;//返回数据全部记录
                        returnData.recordsFiltered = result.total;//后台不实现过滤功能，每次查询均视作全部结果
                        returnData.data = result.data;//返回的数据列表
                        recordsTotal = result.total;//返回的数据列表
                        callback(returnData);
                    }, 200);
                });

            }
        });

        laydate.render({
            elem: '#start'
            ,type: 'date'
            ,format: 'yyyy-MM-dd'
            ,max:new Date().format('yyyy-MM-dd')
            ,done: function(value, date){
                var end_date=$('#end').val();
                if(end_date && new Date(Date.parse(value.replace(/-/g,"/")))>new Date(Date.parse(end_date.replace(/-/g,"/")))){
                    alertError('开始时间不能大于结束时间');
                    $('#start').val('')
                }
            }
        });
        laydate.render({
            elem: '#end'
            ,type: 'date'
            ,format: 'yyyy-MM-dd'
            ,max:new Date().format('yyyy-MM-dd')
            ,done: function(value, date){
                var start_date=$('#start').val();
                if(start_date && new Date(Date.parse(value.replace(/-/g,"/")))<new Date(Date.parse(start_date.replace(/-/g,"/")))){
                    alertError('结束时间不能小于开始时间');
                    $('#end').val('')
                }
            }
        });
    });

</script>
</@t.plat_body>